home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Mania 4
/
MacMania 4.toast
/
/
Games&Education
/
CivHack PM3
/
CivHackPM.c
next >
Wrap
C/C++ Source or Header
|
1996-01-08
|
2KB
|
89 lines
// CivHackPCI3
// Little hack to get Civilization game to run on PCI Macs.
// I make no promises that this won't crash your machine, etc. You have been
// warned.
// Jan 8 '95
// Gavriel State:
// gav@magmacom.com
#include "Types.h"
#include "QuickDraw.h"
#include "Windows.h"
#include "Memory.h"
#include "Resources.h"
#include "OSUtils.h"
#include "SetupA4.h"
#include "A4Stuff.h"
#include "LowMem.h"
// Function Prototypes
pascal void PatchSetCCursor(CCrsrHandle cCrsr);
int main(void);
// SetCCursor ProcPtr type definition
typedef pascal void (*SetCCursorProcPtr)(CCrsrHandle cCrsr);
// Declare a global pointer to save the original SetCCursor address in
SetCCursorProcPtr gOldSetCCursor;
//---------------------------------------------------------------------------
// The patch function
//---------------------------------------------------------------------------
pascal void PatchSetCCursor(CCrsrHandle cCrsr)
{
GDHandle savedGD;
// Set up A4 globals
EnterCallback();
// Here's the magic: SetCCursor *should* respect the low mem
// TheGDevice variable. On the PowerMacs though, it doesn't.
// We fix this by saving and restoring the variable before/after
// the actual call to SetCCursor
// Save theGDevice
savedGD = LMGetTheGDevice();
// Call the original routine
(*gOldSetCCursor)(cCrsr);
// Restore theGDevice
LMSetTheGDevice(savedGD);
// Tear down A4 globals
ExitCallback();
}
//---------------------------------------------------------------------------
// The INIT main and patch installer.
//---------------------------------------------------------------------------
int main(void)
{
Handle H;
EnterCodeResource(); // Set up for globals
PrepareCallback();
// Set up the patch - the INIT *must* be in the Sysheap
H = GetResource('INIT',0);
if (H)
{
// Detach and lock the patch
DetachResource(H);
HLock(H);
HNoPurge(H);
// Get the old address
gOldSetCCursor = (SetCCursorProcPtr)NGetTrapAddress(_SetCCursor, ToolTrap);
// Install the patch
NSetTrapAddress((UniversalProcPtr)&PatchSetCCursor, _SetCCursor, ToolTrap);
}
ExitCodeResource(); // Shutdown use of globals (A4).
}